<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <th:block th:fragment="style(title)" th:object="${session.userSidebar}">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="_csrf" th:content="${_csrf.token}"/>
        <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
        <title th:text="'STiger | ' + (${#strings.isEmpty(title)} ? *{currentMenuPathQueue.get(currentMenuPathQueue.size()-1).menu.menuName} : ${title})">STiger | Admin</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" th:href="@{/adminlte/plugins/fontawesome-free/css/all.min.css}">
        <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
        <link rel="stylesheet" th:href="@{/adminlte/dist/css/adminlte.min.css}">
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700">
        <style>
            .toasts-top-right {
                position: absolute;
                right: 0;
                top: 0;
                z-index: 2040;
            }
            .table td {
                vertical-align: middle;
            }
        </style>
    </th:block>
</head>
<body>

<th:block th:fragment="ui-header">
    <nav class="main-header navbar navbar-expand navbar-dark">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
            </li>
        </ul>
        <ul class="navbar-nav ml-auto">
            <li class="nav-item dropdown user-menu">
                <a href="javascript:void(0);" class="nav-link dropdown-toggle" data-toggle="dropdown">
                    <span class="d-none d-md-inline">欢迎，<strong th:text="${#authentication.principal.shortName}">用户</strong></span>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" th:href="@{/logout}">
                    <i class="fas fa-sign-out-alt"></i>
                </a>
            </li>
        </ul>
    </nav>
</th:block>

<th:block th:fragment="ui-user-sidebar(isMain)">
    <aside class="main-sidebar elevation-4 sidebar-dark-primary">
        <a href="https://github.com/snake19870227/StarTiger/tree/master/StarTiger-admin" class="brand-link" target="_blank">
            <img th:src="@{/images/logo.jpg}" alt="AdminLTE Logo"
                 class="brand-image img-circle elevation-3" style="opacity:.8">
            <span class="brand-text font-weight-light">STiger Admin</span>
        </a>
        <div class="sidebar">
            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column nav-flat" data-widget="treeview" role="menu" data-accordion="false">
                    <li class="nav-item">
                        <a th:href="@{/main}" th:class="'nav-link' + (${isMain} ? ' active' : '')">
                            <i class="nav-icon fas fa-home"></i>
                            <p>主页</p>
                        </a>
                    </li>
                    <th:block th:each="menuItem : ${session.userSidebar.items}">
                        <li th:class="'nav-item' + (${menuItem.hasChild} ? ' has-treeview' : '') + (${menuItem.active} ? ' menu-open' : '')">
                            <a href="javascript:void(0);" th:class="'nav-link' + (${menuItem.active} ? ' active' : '')">
                                <i class="nav-icon fas fa-layer-group"></i>
                                <p>[[${menuItem.menu.menuName}]]<i class="fas fa-angle-left right"></i></p>
                            </a>
                            <ul th:if="${menuItem.hasChild}" class="nav nav-treeview">
                                <th:block th:each="childItem : ${menuItem.childItems}">
                                    <li class="nav-item">
                                        <a th:href="@{/routing(menuCode=${childItem.menu.menuCode})}" th:class="'nav-link' + (${childItem.active} ? ' active' : '')">
                                            <i class="fas fa-list nav-icon"></i>
                                            <p th:text="${childItem.menu.menuName}">功能菜单</p>
                                        </a>
                                    </li>
                                </th:block>
                            </ul>
                        </li>
                    </th:block>
                </ul>
            </nav>
        </div>
    </aside>
</th:block>

<th:block th:fragment="ui-content-header(showHeader, headerName, showPath)" th:object="${session.userSidebar}">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div th:if="${showHeader}" class="col-sm-6">
                    <h1 th:if="${not #strings.isEmpty(headerName)}"
                        th:text="${headerName}">主页</h1>
                    <h1 th:if="${#strings.isEmpty(headerName)}"
                        th:text="*{currentMenuPathQueue.get(currentMenuPathQueue.size()-1).menu.menuName}">主页</h1>
                </div>
                <div th:if="${showPath}" class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li th:each="menuItem,row : *{currentMenuPathQueue}"
                            th:text="${menuItem.menu.menuName}"
                            th:class="'breadcrumb-item' + (*{currentMenuPathQueue.size()} == ${row.count} ? ' active' : '')"></li>
                    </ol>
                </div>
            </div>
        </div>
    </section>
</th:block>

<th:block th:fragment="ui-footer">
    <footer class="main-footer">
        <div class="float-right d-none d-sm-block">
            <b>Version</b> [[${#servletContext.getAttribute('projectVersion')}]]
        </div>
        <strong>源码: <a href="https://github.com/snake19870227/StarTiger">STiger Admin</a>.</strong>
    </footer>
</th:block>

<th:block th:fragment="ui-page(pageObj, searchMethod)">
    <nav aria-label="Page navigation example">
        <ul class="pagination justify-content-center" th:attr="data-page-method=${searchMethod}">
            <li th:class="'page-item' + (${pageObj.current == 1} ? ' disabled' : '')">
                <a class="page-link" href="javascript:void(0);"
                   onclick="Proj.toPage(this, 1)">首页</a>
            </li>
            <li th:if="${pageObj.current != 1}" class="page-item">
                <a class="page-link" href="javascript:void(0);"
                   th:onclick="'Proj.toPage(this, ' + ${pageObj.current - 1} + ')'">上一页</a>
            </li>
            <li th:each="item : ${pageObj.rainbow}"
                th:class="'page-item' + (${pageObj.current == item} ? ' active disabled' : '')">
                <a class="page-link" href="javascript:void(0);"
                   th:onclick="'Proj.toPage(this, ' + ${item} + ')'" th:text="${item}">1</a>
            </li>
            <li th:if="${pageObj.current < pageObj.pages}" class="page-item">
                <a class="page-link" href="javascript:void(0);"
                   th:onclick="'Proj.toPage(this, ' + ${pageObj.current + 1} + ')'">下一页</a>
            </li>
            <li th:class="'page-item' + (${pageObj.current == pageObj.pages || pageObj.pages == 0} ? ' disabled' : '')">
                <a class="page-link" href="javascript:void(0);"
                   th:onclick="'Proj.toPage(this, ' + ${pageObj.pages} + ')'">末页</a>
            </li>
        </ul>
    </nav>
</th:block>

<th:block th:fragment="script-frame">
    <script th:src="@{/adminlte/plugins/jquery/jquery.js}"></script>
    <script th:src="@{/adminlte/plugins-ext/jquery-form/jquery.form.js}"></script>
    <script th:src="@{/adminlte/plugins/bootstrap/js/bootstrap.bundle.js}"></script>
    <script th:src="@{/adminlte/dist/js/adminlte.js}"></script>
</th:block>
<th:block th:fragment="script-stiger">
    <input type="hidden" id="runningMode"
           th:value="${#arrays.contains(#servletContext.getAttribute('activeProfiles'), 'dev')} ? 'dev' : 'notdev'" />
    <input type="hidden" id="context-path" th:value="${#servletContext.contextPath}">
    <script th:src="@{/js/Proj.js}"></script>
    <script th:src="@{/js/HttpUtil.js}"></script>
</th:block>
</body>
</html>